<form method="post" class="form-horizontal pd10" <if condition="$user_info['school']">style="display:none"
    </if> id="apply_scholarship" action="
    <{:U( 'User/students_info')}>">
        <{:displayFormHtml( "studentsForm",$user_info)}>
            <div class="form-group">
                <div class="col-sm-2"></div>
                <div class="col-sm-9">
                    <button type="button" class="btn-primary btn border-radius-none btn-lg apply_scholarship_btn mgt10">保存个人信息
                    </button>
                    <a data-type="link" href="/BoxApi/Index/logout" class="btn-info btn border-radius-none btn-lg mgt10">使用其它帐号登录</a>
                </div>
            </div>
            <!--  <div class="mt15 box-btn boot-fixed"> <a href="" class="btn btn-blk">提交</a> </div>-->
</form>
<form method="post" data-type="ajaxSubmit" data-type="validate" class="form-horizontal pd10" <if condition="!$user_info['school']">style="display:none"
    </if> id="apply_scholarship_2" action="
    <{:U( 'User/agreement')}>">
        <div class="form-group">
            <div style=" max-height:300px; width:98%; overflow-y:auto; padding:0px 20px;">
                <{:dict( 'agreement_text')}>
            </div>
        </div>
        <div style="border-bottom:1px solid #EAEAEA"></div>
        <div class="form-group" align="center">
            <label class="checkbox-inline  padding-bottom-lg">
                <input type="checkbox" name="tongyi" value="1">我已阅读并同意 </label>
        </div>
        <div class="form-group">
            <div class="col-sm-2"></div>
            <div class="col-sm-9">
                <button type="submit" class="btn-primary btn " style="width:80%">同意</button>
            </div>
        </div>
</form>
<script>
$(document).on("validateReady",function(){
     $("#apply_scholarship_2").bootstrapValidator({
            // excluded: ':disabled',
            submitHandler: null,
            trigger: null,
            fields: {
                tongyi: {
                    validators: {
                        notEmpty: {
                            message: '请选择同意使用协议'
                        }
                    }
                },
            }
        });

        $("#apply_scholarship").bootstrapValidator({
            // excluded: ':disabled',
            submitHandler: null,
            trigger: null,
            fields: {
                school_id: {
                    validators: {
                        notEmpty: {
                            message: '请选择所在学校'
                        }
                    }
                },


            }
        });

        $("#apply_scholarship").on("ajaxSubmitSuccess", function(event, data) {
            var data = JSON.parse(data);
            if (data.error == 0) {
                dialog(data.msg);
                //                if ($("#apply_scholarship").length > 0) {
                //                    $("#apply_scholarship").hide();
                //                    $("#apply_scholarship_2").show();
                //                    $("#students_info .modal-title").html('同意使用协议');
                //                } else {
                //                    window.location.reload();
                //                }
                window.location.reload();
            } else {
                dialog(data.msg);
            }
        })

        $("#apply_scholarship_2").on("ajaxSubmitSuccess", function(event, data) {
            if ($(this).parents(".modal_popup").length > 0) {
                $(this).parents(".modal_popup").modal("hide");
                $(this).parents(".modal_popup").hide();
            } else {
                window.location.href = "/";
            }
        })

        $(".apply_scholarship_btn").click(function() {
            var _this = $(this).parents("form");
            hiApp.confirm("学校信息提交后不得修改，确认保存信息吗？", function() {
                // alert($(_this).attr('id'));
                hiApp.ajaxSubmit(_this);
                // $("#apply_scholarship").ajaxSubmit();
            })
        })
});

</script>
